using System.Data;
using VanTaiProperty;
namespace VanTaiData
{
    public class ClsTmUnitController
    {
        private clsConnect cls = new clsConnect();
        private DataTable dt;
        #region Getdata
        public DataTable BindGirdTmUnit(string keywords)
        {
            return cls.Search("sp_TMUnit", "@KeyWords", keywords);
        }
        public DataTable BindGirdTmUnitDetail(int id)
        {
            return cls.LayDuLieuParameter("sp_TMUnit_Detail", "@Unit_ID", id);
        }
        #endregion

        #region Insert
        public bool InsertTmUnit(ClsTmUnitProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Unit_Alias", data.Unit_Alias);
            cls.AddParameter("@Unit_Name", data.Unit_Name);
            cls.AddParameter("@Unit_Rate", data.Unit_Rate);
            cls.AddParameter("@Unit_Note", data.Unit_Note);
            cls.AddParameter("@Unit_MaCha", data.Unit_MaCha);
            cls.AddParameter("@Unit_NameE", data.Unit_NameE);
            cls.AddParameter("@Unit_NameC", data.Unit_NameC);
            cls.ExecuteNonQuery("sp_TMUnit_Insert");
            return true;
        }
        #endregion

        #region Update
        public bool UpdateTmUnit(ClsTmUnitProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Unit_ID", data.Unit_ID);
            cls.AddParameter("@Unit_Alias", data.Unit_Alias);
            cls.AddParameter("@Unit_Name", data.Unit_Name);
            cls.AddParameter("@Unit_Rate", data.Unit_Rate);
            cls.AddParameter("@Unit_Note", data.Unit_Note);
            cls.AddParameter("@Unit_MaCha", data.Unit_MaCha);
            cls.AddParameter("@Unit_NameE", data.Unit_NameE);
            cls.AddParameter("@Unit_NameC", data.Unit_NameC);
            cls.ExecuteNonQuery("sp_TMUnit_Update");
            return true;
        }
        #endregion

        #region Delete
        public bool DeleteTmUnit(int id)
        {
            cls.Delete("sp_TMUnit_Delete", "@Unit_ID", id);
            return true;
        }
        public bool TMUnit_Check_Delete_TMDO(int id)
        {
            dt = cls.LayDuLieuParameter("sp_TMUnit_Check_Delete_TMDO", "@Id", id);
            if (dt.Rows.Count > 0)
                return true;
            return false;
        }
        #endregion
    }
}